/**
 *
 * Storage 通用存储文件定义
 */

module.exports = {
    // 设置值
    setItem(key, value, module_name) {
        if (module_name) {
            let module_name_info = this.getItem(module_name);
            module_name_info[key] = value;
            uni.setStorageSync(module_name, module_name_info);
        } else {
            uni.setStorageSync(key, value);
        }
    },
    // 获取值
    getItem(key, module_name) {
        if (module_name) {
            let val = this.getItem(module_name);
            if (val) {
                return val[key];
            }
            return '';
        } else {
            return uni.getStorageSync(key);
        }
    },
    // 删除或者清空值
    clear(key) {
        if (key) {
            uni.removeStorageSync(key);
        } else {
            uni.clearStorageSync();
        }
    },
    getSystemInfo() {
        return uni.getSystemInfoSync();
    }
};
